package com.boe.common.util.freemark.base;

import lombok.*;
import com.boe.common.util.ClassUtil;
import com.boe.common.util.freemark.P0Error;
import com.boe.common.util.freemark.BaseMethodModelFreemarker;
import freemarker.template.TemplateModelException;

import java.lang.reflect.Field;
import java.util.List;


public class FreemarkerFieldIsEnumList extends BaseMethodModelFreemarker {
    @Override
    public Object exec(List list) throws TemplateModelException {
        var paramValue = getFreemarkerParameter(list.get(0));
        if (paramValue instanceof Field) {
            return ClassUtil.isListEnum((Field) paramValue);
        }
        throw new P0Error(paramValue);
    }
}
